package com.liuyu.common.framework.power3.service.impl;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.liuyu.common.framework.common.service.security.vo.AddPowerVo;
import com.liuyu.common.framework.power.model.RequestInfoWrapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @ClassName OrderPower3ExtendServiceImpl
 * @Author: liuyu
 * @Date: Created in 2021/6/23 11:42
 * @Version: 1
 * @Modified By:
 */
@Service("orderPower3ExtendService")
public class OrderPower3ExtendServiceImpl extends AbstractPower3ExtendServiceImpl {
    private static final String PREFIX = "44";
    private static final String ORDER = "order";

    @Override
    public String getCode() {
        return ORDER;
    }

    @Override
    public AddPowerVo getAddPowerVo() {
        RequestInfoWrapper requestInfoWrapper = getRequestInfoWrapper();
        //个性定制 todo
//        requestInfoWrapper.getAddPowerVo().setTaskCodes(Lists.newArrayList(SelfConstants.TaskCode.ORDER_QUERY));
        if (requestInfoWrapper.getComCode().startsWith(PREFIX)) {
            Map<String, List<String>> map = Maps.newHashMapWithExpectedSize(2);
            map.put(AddPowerVo.POWER_FILE_COM, Lists.newArrayList("a.com_code"));
            map.put(AddPowerVo.POWER_FILE_PVT, Lists.newArrayList("a.create_code"));
            requestInfoWrapper.getAddPowerVo().setPowerFieldMap(map);
        } else {
            Map<String, List<String>> map = Maps.newHashMapWithExpectedSize(2);
            map.put(AddPowerVo.POWER_FILE_COM, Lists.newArrayList("a.corp_com_code"));
            map.put(AddPowerVo.POWER_FILE_PVT, Lists.newArrayList("a.create_code"));
            requestInfoWrapper.getAddPowerVo().setPowerFieldMap(map);
        }
        return requestInfoWrapper.getAddPowerVo();
    }
}
